class Solution {
public:
    int halveArray(vector<int>& nums)
    {
        double sum = accumulate(nums.begin(), nums.end(), 0.0);
        double half = sum / 2.0;
        double tar = 0.0;
        long long ans = 0;
        priority_queue<double> q(nums.begin(), nums.end());
        while (tar < half)
        {
            ans++;
            double x = q.top();
            tar += x / 2.0;
            q.pop();
            q.push(x / 2.0);
        }
        return ans;
    }
};